<template>
  <PageLayout>
    <div class="table-box">
      <div class="head-box">
        <div class="title">套餐列表</div>
        <!-- <a-space :size="16">
          <a-button type="primary" @click="edit()">参数图片设置</a-button>
        </a-space> -->
      </div>
      <div class="bg-fff">
        <!-- :apiFetch="apiFetch"  -->
        <BasicTable
          ref="tableRef"
          :columns="columns"
          :query-params="queryData"
          :apiFetch="postPackagePage"
        >
          <template #bodyCell="{ column, record }">
            <template v-if="column.key === 'name'">
              <div class="d-flex a-center">
                <div>
                  {{ record.name }}
                </div>
                <edit-outlined @click="edit(record, 'name')" />
              </div>
            </template>
            <template v-if="column.key === 'amount'">
              <div class="d-flex a-center">
                <div>
                  {{ record.amount }}
                </div>
                <edit-outlined @click="edit(record, 'amount')" />
              </div>
            </template>
            <template v-if="column.key === 'content'">
              <div class="d-flex a-center">
                <div>
                  {{ record.content }}
                </div>
                <edit-outlined @click="edit(record, 'content')" />
              </div>
            </template>
            <template v-if="column.key === 'consume'">
              <div class="d-flex a-center">
                <div>
                  <div>洗发水消耗量:{{ record.consumeShampoo }}</div>
                  <div>护发素消耗量:{{ record.consumeConditioner }}</div>
                  <div>养发液消耗量:{{ record.consumeHairtonic }}</div>
                </div>
                <edit-outlined @click="edit(record, 'consume')" />
              </div>
            </template>
          </template>
        </BasicTable>
      </div>
    </div>
    <ConsumeModal
      ref="cusumeModalRef"
      :data="dataDetail"
      :type="type"
      @ok="tableRef.fetch()"
    ></ConsumeModal>
  </PageLayout>
</template>

<script setup>
import ConsumeModal from "./components/consume-modal.vue";
import { postPackagePage } from "@/api/common";
import { useStoreCommonEnum } from "@/store";
import { comfirmModal } from "@/hooks/useModal";
import { message } from "ant-design-vue";
const storeCommonEnum = useStoreCommonEnum();
const router = useRouter();

const columns = [
  {
    title: "序号",
    dataIndex: "index",
    width: "80px",
    customRender: (record) => `${record.index + 1}`,
  },
  {
    title: "套餐名称",
    dataIndex: "name",
    key: "name",
    width: "150px",
    ellipsis: true,
  },
  {
    title: "信用分",
    dataIndex: "amount",
    key: "amount",
    width: "150px",
    ellipsis: true,
  },
  {
    title: "套餐内容描述",
    dataIndex: "content",
    key: "content",
    width: "150px",
    ellipsis: true,
  },
  // {
  //   title: "消耗量",
  //   dataIndex: "consume",
  //   key: "consume",
  //   width: "150px",
  //   ellipsis: true,
  // },
  // {
  //   title: "参数",
  //   dataIndex: "nickname",
  //   key: "nickname",
  //   width: "150px",
  //   ellipsis: true,
  // },

 
];

const queryData = reactive({});
const tableRef = ref(null);
const onQueryDataByParams = (params) => {
  for (let key in params) {
    queryData[key] = params[key];
  }
  tableRef.value.refreshTableData();
};
const type = ref("");
const dataDetail = ref({});
const cusumeModalRef = ref(null);
const edit = (record, val) => {
  console.log(33);
  dataDetail.value = record;
  type.value = val;
  setTimeout(() => {
    cusumeModalRef.value.visible = true;
  }, 0);
};

const dataSource = ref(
  Array.from({ length: 11 }, () => ({
    spaceName: "2121",
  }))
);
</script>

<style lang="less" scoped></style>
